﻿using Acme.SmartWMS.Inbound.PurchaseService;
using Microsoft.AspNetCore.Mvc;
using System.Linq.Dynamic.Core;
using System.Threading.Tasks;

namespace Acme.SmartWMS.Web.Controllers.Inbound
{
    public class PurchaseController : Controller
    {
        /// <summary>
        /// 进货通知明细服务类
        /// </summary>
        private readonly IPurchaseAppService _purchaseAppService;
        public PurchaseController(IPurchaseAppService purchaseAppService)
        {
            _purchaseAppService = purchaseAppService;
        }

        public IActionResult PurchaseList()
        {
            return View();
        }
        /// <summary>
        /// 获取进货通知明细显示 查询 分页
        /// </summary>
        /// <param name="page"></param>
        /// <param name="limit"></param>
        /// <param name="notificationNo"></param>
        /// <param name="customerName"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<JsonResult> GetPurchaseList(int page, int limit, string? notificationNo, string? customerName)
        {
            var purchase= await _purchaseAppService.GetPurchaseList(page, limit, notificationNo, customerName);
            return Json(new { code = 0, data = purchase.Queryable,count=purchase.RowCount });
        }
    }
}
